-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add picker to pick value from record #246
Conversation
bddedbf
to
9aa677d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
package picker | ||
|
||
var _ Picker = ConverterPicker{} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add var _ Picker = NullablePickers{}
too ?
case 0: | ||
return v, nil | ||
case 1: | ||
return ncs[0].Convert(v) | ||
} | ||
return ncs.convertSlow(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to process case1?
if len(nsc) == 0 {
return v, nil
}
return ncs.convertSlow(v)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It‘s for performance. It's need not to loop.
switch len(cs) { | ||
case 0: | ||
return v, nil | ||
case 1: | ||
return cs[0].Convert(v) | ||
} | ||
return cs.convertSlow(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to process case 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as #246 (comment) .
if !nullHandled && c.Nullable != nil { | ||
converters = append(converters, NullableConverter{ | ||
Nullable: c.Nullable, | ||
}) | ||
} | ||
|
||
if c.Nullable != nil { | ||
if c.DefaultValue != nil { | ||
converters = append(converters, DefaultConverter{ | ||
Value: *c.DefaultValue, | ||
}) | ||
} else { | ||
converters = append(converters, NullConverter{ | ||
Value: c.NullValue, | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can combine them ?
if c.Nullable != nil {
if !nullHandled {
converters = append(converters, NullableConverter{
Nullable: c.Nullable,
})
}
if c.DefaultValue != nil {
converters = append(converters, DefaultConverter{
Value: *c.DefaultValue,
})
} else {
converters = append(converters, NullConverter{
Value: c.NullValue,
})
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌🏻
What type of PR is this?
What problem(s) does this PR solve?
Issue(s) number:
Description:
Ref #245
How do you solve it?
Special notes for your reviewer, ex. impact of this fix, design document, etc: